<?php

class Simplify
{

  protected static $application;

  protected static $request;

  protected static $router;

  /**
   *
   * @return ApplicationController
   */
  public static function getInstance()
  {
    if (empty(self::$application)) {
      global $config;

      self::$application = new ApplicationControllerImpl();
      self::$application->request(self::request());
    }

    return self::$application;
  }

  /**
   *
   * @return Config
   */
  public static function config()
  {
    global $config;
    return $config;
  }

  /**
   *
   * @return Request
   */
  public static function request()
  {
    if (empty(self::$request)) {
      self::$request = new Request();
    }

    return self::$request;
  }

  /**
   *
   * @return Router
   */
  public static function router()
  {
    if (empty(self::$router)) {
      self::$router = new Router();
    }

    return self::$router;
  }

  /**
   *
   * @return Response
   */
  public static function response()
  {
    return self::getInstance()->response();
  }

}
